max = 10;
prog = initProgInd("Counting: ", "done");
for (c in 1:max)
{
Sys.sleep(0.10);
prog = updateProgInd(c/max, prog);
}
printFlush("");
printFlush("Example 2:");
prog = initProgInd();
for (c in 1:max)
{
Sys.sleep(0.10);
prog = updateProgInd(c/max, prog);
}
printFlush("");
## Example of a significant slowdown:
## Without progress indicator:
system.time( {a = 0; for (i in 1:10000) a = a+i; } )
## With progress indicator, some 50 times slower:
system.time(
{
prog = initProgInd("Counting: ", "done");
a = 0;
for (i in 1:10000)
{
a = a+i;
prog = updateProgInd(i/10000, prog);
}
}
)
Run the code above in your browser using DataLab